let pwd=document.getElementById("pwd")
let pwd_again=document.getElementById("pwd_again")
let submit = document.getElementById("submit")
let email = document.getElementById("email")
let f_name = document.getElementById("f_name")
let g_name = document.getElementById("g_name")
let username = document.getElementById("username")
let address = document.getElementById("address")

pwd_again.addEventListener("keyup",(event)=>{
    if (pwd.value==pwd_again.value) {
        document.getElementById("submit").removeAttribute("disabled")
        document.getElementById("notice").innerText=""
        document.getElementById("submit").classList.add("btn")
        document.getElementById("submit").classList.add("btn-success")
    }
    else {

        document.getElementById("submit").setAttribute("disabled","disabled")
        document.getElementById("notice").innerText="Two Password Input Different"
        document.getElementById("submit").classList.remove("btn-success")
    }
})
document.getElementById("submit").addEventListener("click",(event)=>{
    $.post("/pub/insertUser",{
        "fammily_name":f_name.value,
        "given_name":g_name.value,
        "address":address.value,
        "email":email.value,
        "password":pwd_again.value
    },function (res) {
        alert(`Sign Up Sucess,Your Login Account ID is ${res.data.randomID}`)
    },"json")
})
document.getElementById("Back").addEventListener("click",(event)=>{
  document.location="./home.html"
})
